<?php if(!defined('HDPHP_PATH'))EXIT;
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."attribute`");
$db->exe("CREATE TABLE `".$db_prefix."attribute`".$db_prefix." (
  `".$db_prefix."atid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '类型属性ID',
  `".$db_prefix."atname`".$db_prefix." varchar(20) NOT NULL DEFAULT '' COMMENT '类型属性名称',
  `".$db_prefix."at_value`".$db_prefix." varchar(45) NOT NULL DEFAULT '' COMMENT '类型属性值',
  `".$db_prefix."at_type`".$db_prefix." tinyint(4) NOT NULL DEFAULT '0' COMMENT '属性类型',
  `".$db_prefix."type_tid`".$db_prefix." int(10) unsigned NOT NULL,
  PRIMARY KEY (`".$db_prefix."atid`".$db_prefix."),
  KEY `".$db_prefix."fk_attribute_type1_idx`".$db_prefix." (`".$db_prefix."type_tid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 COMMENT='属性'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."brand`");
$db->exe("CREATE TABLE `".$db_prefix."brand`".$db_prefix." (
  `".$db_prefix."bid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '品牌ID',
  `".$db_prefix."bname`".$db_prefix." varchar(10) NOT NULL DEFAULT '' COMMENT '品牌名称',
  `".$db_prefix."logo`".$db_prefix." varchar(45) NOT NULL DEFAULT '' COMMENT '品牌logo',
  `".$db_prefix."sort`".$db_prefix." tinyint(6) NOT NULL DEFAULT '0' COMMENT '品牌排序',
  `".$db_prefix."ishot`".$db_prefix." tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否热门',
  PRIMARY KEY (`".$db_prefix."bid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 COMMENT='品牌表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."category`");
$db->exe("CREATE TABLE `".$db_prefix."category`".$db_prefix." (
  `".$db_prefix."cid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '分类ID',
  `".$db_prefix."cname`".$db_prefix." varchar(20) NOT NULL DEFAULT '' COMMENT '分类名称',
  `".$db_prefix."pid`".$db_prefix." tinyint(10) NOT NULL DEFAULT '0' COMMENT '父级ID',
  `".$db_prefix."csort`".$db_prefix." tinyint(10) NOT NULL DEFAULT '0' COMMENT '排序',
  `".$db_prefix."type_tid`".$db_prefix." int(10) unsigned NOT NULL,
  PRIMARY KEY (`".$db_prefix."cid`".$db_prefix."),
  KEY `".$db_prefix."fk_category_type_idx`".$db_prefix." (`".$db_prefix."type_tid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COMMENT='分类表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."goods`");
$db->exe("CREATE TABLE `".$db_prefix."goods`".$db_prefix." (
  `".$db_prefix."gid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '商品ID',
  `".$db_prefix."gname`".$db_prefix." char(60) NOT NULL DEFAULT '' COMMENT '商品名称',
  `".$db_prefix."gnumber`".$db_prefix." int(10) NOT NULL DEFAULT '0' COMMENT '商品编号',
  `".$db_prefix."unit`".$db_prefix." char(1) NOT NULL DEFAULT '' COMMENT '单位',
  `".$db_prefix."marketprice`".$db_prefix." int(8) NOT NULL DEFAULT '0' COMMENT '市场价',
  `".$db_prefix."shopprice`".$db_prefix." int(8) NOT NULL DEFAULT '0' COMMENT '商城价',
  `".$db_prefix."img`".$db_prefix." varchar(50) NOT NULL DEFAULT '' COMMENT '图片',
  `".$db_prefix."click`".$db_prefix." int(8) unsigned NOT NULL DEFAULT '0' COMMENT '点击次数',
  `".$db_prefix."addtime`".$db_prefix." int(10) NOT NULL DEFAULT '0' COMMENT '上架时间',
  `".$db_prefix."user_uid`".$db_prefix." int(10) unsigned NOT NULL,
  `".$db_prefix."brand_bid`".$db_prefix." int(10) unsigned NOT NULL,
  `".$db_prefix."category_cid`".$db_prefix." int(10) unsigned NOT NULL,
  `".$db_prefix."type_tid`".$db_prefix." int(10) unsigned NOT NULL,
  PRIMARY KEY (`".$db_prefix."gid`".$db_prefix."),
  KEY `".$db_prefix."fk_goods_user1_idx`".$db_prefix." (`".$db_prefix."user_uid`".$db_prefix."),
  KEY `".$db_prefix."fk_goods_brand1_idx`".$db_prefix." (`".$db_prefix."brand_bid`".$db_prefix."),
  KEY `".$db_prefix."fk_goods_type1_idx`".$db_prefix." (`".$db_prefix."type_tid`".$db_prefix."),
  KEY `".$db_prefix."fk_goods_category1_idx`".$db_prefix." (`".$db_prefix."category_cid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COMMENT='商品表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."type`");
$db->exe("CREATE TABLE `".$db_prefix."type`".$db_prefix." (
  `".$db_prefix."tid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '类型ID',
  `".$db_prefix."tname`".$db_prefix." varchar(20) NOT NULL DEFAULT '' COMMENT '类型名称',
  PRIMARY KEY (`".$db_prefix."tid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=20 DEFAULT CHARSET=utf8 COMMENT='类型'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."user`");
$db->exe("CREATE TABLE `".$db_prefix."user`".$db_prefix." (
  `".$db_prefix."uid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '用户ID',
  `".$db_prefix."username`".$db_prefix." varchar(20) NOT NULL DEFAULT '' COMMENT '用户名',
  `".$db_prefix."password`".$db_prefix." char(32) NOT NULL DEFAULT '' COMMENT '密码',
  `".$db_prefix."nickname`".$db_prefix." varchar(20) NOT NULL DEFAULT '' COMMENT '昵称',
  `".$db_prefix."sex`".$db_prefix." enum('男','女') NOT NULL DEFAULT '男' COMMENT '性别',
  `".$db_prefix."mobile`".$db_prefix." tinyint(11) NOT NULL COMMENT '手机号',
  `".$db_prefix."email`".$db_prefix." varchar(30) NOT NULL DEFAULT '' COMMENT '邮箱',
  `".$db_prefix."birthday`".$db_prefix." date DEFAULT NULL COMMENT '生日',
  `".$db_prefix."is_Lock`".$db_prefix." tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否被锁定',
  `".$db_prefix."is_Admin`".$db_prefix." tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否是后台用户',
  `".$db_prefix."face`".$db_prefix." varchar(100) NOT NULL DEFAULT 'Upload/default.jpg',
  PRIMARY KEY (`".$db_prefix."uid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='用户表'");
